package com.atguigu.tingshu.order.adapter;

import com.atguigu.tingshu.common.rabbit.constant.MqConst;
import com.atguigu.tingshu.common.rabbit.service.RabbitService;
import com.atguigu.tingshu.order.service.OrderInfoService;
import com.atguigu.tingshu.vo.order.OrderInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**TODO 微信支付
 * @Author：yyj
 * @Package：com.atguigu.tingshu.order.adapter
 * @Project：tingshu_parent240829
 * @name：WxPayWayImpl
 * @Date：2025/2/11 18:39
 * @Filename：WxPayWayImpl
 */
@Component
public class WxPayWayImpl implements PayWay{
    @Autowired
    private OrderInfoService orderInfoService;
    @Autowired
    private RabbitService rabbitService;
    @Override
    public Boolean supportPayWay(String payWay) {
        return "1101".equals(payWay);
    }

    /*
     * @description: TODO 微信支付
     * @author: yyj
     * @date: 2025-02-13
    */
    @Override
    public void payWay(OrderInfoVo orderInfoVo, String orderNo, Long userId) {
        //1.保存订单信息
        orderInfoService.saveOrderInfo(orderInfoVo,orderNo,userId);
        //2.向延迟插件的队列中发送一个订单消息(让该订单在30min之后订单状态修改为已关闭)
        rabbitService.sendDealyMessage(MqConst.EXCHANGE_CANCEL_ORDER, MqConst.EXCHANGE_CANCEL_ORDER, orderNo,30);
    }
}